import { createApp } from 'vue'
import { createPinia } from 'pinia'
import WujieVue from 'wujie-vue3'
import { credentialsFetch } from './utils'
import router from './routes'
import App from './App.vue'

import '@/assets/style/index.less'

// 注册基础组件(antd 自定义)
import BaseUI from '@/components/ui'

// 自动检测版本更新
import './utils/autoUpdate'

// 页面权限控制
import './routes/permission'
import { ENV_CONFIG } from '@/config'

const app = createApp(App)

const { setupApp, preloadApp } = WujieVue
const env = (ENV_CONFIG as any)[import.meta.env.MODE]

setupApp({
  name: 'react-subapp',
  url: env.reactAppUrl,
  exec: true,
  props: {
    msg: 'hello data',
  },
  fetch: credentialsFetch,
})

preloadApp({ name: 'react-subapp', url: env.reactAppUrl })

app.use(WujieVue).use(BaseUI).use(createPinia()).use(router).mount('#app')
